
#include <bits/stdc++.h>

const int MAX_VOLUME = 20;

using namespace std;

template <class T>
class vecList{
private:
    T *data;
    int len;
    int size_;
public:
    vecList<T>() {
        data = new T[MAX_VOLUME];
        len = 0;
        size_ = MAX_VOLUME;
    }

    ~vecList<T>() {
        delete data;
        len = 0;
    }
    int getSize() { return len;}
    int operator[](int i) const { return *(this -> data + i) ;}

    void enlarge(int nsize) {
        T *temp = new T[nsize];
        for (int i = 0; i < len; i++)
            temp[i] = data[i];
        data = temp;
        size_ = nsize;
    }

    void push(int n) {
        if (len + 1 >= size_ / 5 * 4)
            enlarge(size_ + MAX_VOLUME / 2);
        data[len] = n;
        len += 1;
    }
    void pop() {
        len -= 1;
    }

};


int main(){
    ios::sync_with_stdio(false);
    vecList<int> v;
    int n ;
    cin >> n;
    for (int i = 1; i<= n; i++) {
        v.push(i);
        if (i % 3 == 0) v.pop();
    }
    cout << v.getSize() << endl;
    for (int i = 0; i < v.getSize(); i++)
        cout << v[i] << ' ';


}
